package org.example.cloud.payment.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class TomcatMonitor {

    @Autowired
    private ServletWebServerApplicationContext applicationContext;

    @Scheduled(cron = "*/60 * * * * ?")
    public void execute(){
        TomcatWebServer tomcatWebServer=(TomcatWebServer) applicationContext.getWebServer();

        String string = tomcatWebServer.getTomcat().getConnector().getProtocolHandler().getExecutor().toString();

        System.out.println(string);
    }

}
